﻿using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExcelHelperSpace
{
    public static class ExcelHelper
    {
        //静态
        static readonly ExcelMapper DefaultExcelMapper = new();

        //初始化接口

        public static IExcelMapper ExcelMapper { get; set; } = DefaultExcelMapper;

        /// <summary>
        /// Excel To List
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="file"></param>
        /// <returns></returns>
        public static IEnumerable<T> SExcelToList<T>(IFormFile file) 
        {
            return ExcelMapper.ExcelToList<T>(file);
        }

        /// <summary>
        /// Excel To List
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="file"></param>
        /// <returns></returns>
        public static IEnumerable<T> SExcelToList<T>(MemoryStream stream)
        {
            return ExcelMapper.ExcelToList<T>(stream);
        }

        /// <summary>
        /// Excel To List
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path">文件路径</param>
        /// <returns></returns>
        public static IEnumerable<T> SExcelToList<T>(string path)
        {
            return ExcelMapper.ExcelToList<T>(path);
        }

        /// <summary>
        /// List To Excel
        /// </summary>
        /// <returns></returns>
        public byte[] GListToExcel<T>(this IEnumerable<T> list, string sheetName = "Sheet1") 
        {

        }

    }
}
